package com.ruoyi.wms.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.wms.mapper.WmsCargoOwnerMapper;
import com.ruoyi.wms.domain.WmsCargoOwner;
import com.ruoyi.wms.service.IWmsCargoOwnerService;

/**
 * 货主信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-01
 */
@Service
public class WmsCargoOwnerServiceImpl implements IWmsCargoOwnerService 
{
    @Autowired
    private WmsCargoOwnerMapper wmsCargoOwnerMapper;

    /**
     * 查询货主信息
     * 
     * @param id 货主信息主键
     * @return 货主信息
     */
    @Override
    public WmsCargoOwner selectWmsCargoOwnerById(Long id)
    {
        return wmsCargoOwnerMapper.selectWmsCargoOwnerById(id);
    }

    /**
     * 查询货主信息列表
     * 
     * @param wmsCargoOwner 货主信息
     * @return 货主信息
     */
    @Override
    public List<WmsCargoOwner> selectWmsCargoOwnerList(WmsCargoOwner wmsCargoOwner)
    {
        // 设置租户ID
        wmsCargoOwner.setTenantId(SecurityUtils.getTenantId());
        return wmsCargoOwnerMapper.selectWmsCargoOwnerList(wmsCargoOwner);
    }

    /**
     * 新增货主信息
     * 
     * @param wmsCargoOwner 货主信息
     * @return 结果
     */
    @Override
    public int insertWmsCargoOwner(WmsCargoOwner wmsCargoOwner)
    {
        wmsCargoOwner.setTenantId(SecurityUtils.getTenantId());
        wmsCargoOwner.setCreateBy(SecurityUtils.getUsername());
        wmsCargoOwner.setCreateTime(DateUtils.getNowDate());
        return wmsCargoOwnerMapper.insertWmsCargoOwner(wmsCargoOwner);
    }

    /**
     * 修改货主信息
     * 
     * @param wmsCargoOwner 货主信息
     * @return 结果
     */
    @Override
    public int updateWmsCargoOwner(WmsCargoOwner wmsCargoOwner)
    {
        wmsCargoOwner.setUpdateBy(SecurityUtils.getUsername());
        wmsCargoOwner.setUpdateTime(DateUtils.getNowDate());
        return wmsCargoOwnerMapper.updateWmsCargoOwner(wmsCargoOwner);
    }

    /**
     * 批量删除货主信息
     * 
     * @param ids 需要删除的货主信息主键
     * @return 结果
     */
    @Override
    public int deleteWmsCargoOwnerByIds(Long[] ids)
    {
        return wmsCargoOwnerMapper.deleteWmsCargoOwnerByIds(ids);
    }

    /**
     * 删除货主信息信息
     * 
     * @param id 货主信息主键
     * @return 结果
     */
    @Override
    public int deleteWmsCargoOwnerById(Long id)
    {
        return wmsCargoOwnerMapper.deleteWmsCargoOwnerById(id);
    }

    /**
     * 根据货主编码查询货主信息
     * 
     * @param ownerCode 货主编码
     * @return 货主信息
     */
    @Override
    public WmsCargoOwner selectWmsCargoOwnerByCode(String ownerCode)
    {
        return wmsCargoOwnerMapper.selectWmsCargoOwnerByCode(ownerCode, SecurityUtils.getTenantId());
    }

    /**
     * 校验货主编码是否唯一
     * 
     * @param wmsCargoOwner 货主信息
     * @return 结果
     */
    @Override
    public boolean checkOwnerCodeUnique(WmsCargoOwner wmsCargoOwner)
    {
        wmsCargoOwner.setTenantId(SecurityUtils.getTenantId());
        return wmsCargoOwnerMapper.checkOwnerCodeUnique(wmsCargoOwner);
    }
}